package pong.business.properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesAccessor {
	
	private static final String PATH = "conf/game.properties";
	
	private static final String PROPERTYNAME_PLAYER = "PLAYER";
	
	private static final String PROPERTYNAME_SIZE = "SIZE";
	
	private static final String PROPERTYNAME_BALL_SPEED = "BALL_SPEED";
	
	private static final String PROPERTYNAME_SPEED_INCREMENT_GAP = "SPEED_INCREMENT_GAP";
	
	private static PropertiesAccessor instance;

	private Properties properties = new Properties();

	private PropertiesAccessor() throws FileNotFoundException, IOException {
		properties.load(new FileInputStream(PATH));
	}

	public static PropertiesAccessor getInstance() throws FileNotFoundException, IOException {
		if(instance == null){
			instance = new PropertiesAccessor();
		}
		return instance;
	}
	

	public String getPlayerName() {
		return properties.getProperty(PROPERTYNAME_PLAYER);
	}
	
	public float getSizeCoefficient() {
		return Float.parseFloat(properties.getProperty(PROPERTYNAME_SIZE));
	}
	
	public int getBallSpeed() {
		return Integer.parseInt(properties.getProperty(PROPERTYNAME_BALL_SPEED));
	}
	
	public long getSpeedIncrementGap() {
		return Long.parseLong(properties.getProperty(PROPERTYNAME_SPEED_INCREMENT_GAP));
	}
}
